<!DOCTYPE HTML>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
		<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
		<title>查看附件</title>
		<link rel="stylesheet" type="text/css" href="../css/mui.min.css" />
		<link rel="stylesheet" type="text/css" href="../css/common.css" />
		<style type="text/css">
			.mui-table-view-chevron .mui-table-view-cell {
				padding-right: 20px!important;
			}
			h5 {
				color: #0062CC;
			}

		</style>
	</head>

	<body>
		<div class="mui-content content-padded_bottom" id="ordrDetailContent">
			<script type="text/template" id="items">
				<ul class="mui-table-view mui-table-view-chevron type_list_spair">
					<li class="mui-table-view-cell detail">
						<div class="mui-table">
							<div class="mui-table-cell mui-col-xs-4">
								<!-- <h5 class="mui-ellipsis">附件：</h5> -->
							</div>
						</div>
						<div class="mui-table">
							<ul class="mui-table-view mui-table-view-chevron type_list_spair" id="accessories">
								<!-- 模板引擎 -->
							</ul>
						</div>
					</li>
				</ul>
			</script>
		</div>
	</body>
	<script type="text/javascript" src="../script/api.js"></script>
	<script src="../script/mui.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../script/common.js" type="text/javascript" charset="utf-8"></script>
	<script src="../script/template.js"></script>
	<script type="text/temmlate" id="tmpList">
		{{each datas as item}}
		<li class="mui-table-view-cell" tapmode onclick="showRemotePicture(baseURL + 'downloadFile?docinfoid='+'{{item.docinfoid}}', '{{item.description}}')">
			<img class="mui-media-object" src="{{item.src}}" />
		</li>
		{{/each}}
	</script>
	<script type="text/temmlate" id="tmpList2">
		{{each datas as item}}
			<li class="mui-table-view-cell" onclick='uploadXlsx("{{item.docinfoid}}", "{{item.description}}")'>
				<span class="mui-h5">{{item.description}}</span>
			</li>
		{{/each}}
	</script>
	<script type="text/javascript">
		// var wonum,
		// 	worktype,
		// 	status,
		// 	desc,
		// 	locations,
		// 	locationDesc,
		// 	cRegion,
		// 	assetnum,
		// 	assetDesc,
		// 	lead,
		// 	leadName,
		// 	schedstart,
		// 	schedfinish,
		// 	workstatus;
		var arr = [];
		apiready = function() {
			onLoadData();
			// Refresh(function() {
			// 	tjsearch();
			// });
		}

		function onLoadData() {
			ajaxrd("queryOrderDetail", {
				workorderid: api.pageParam.workorderid,
				wonum: api.pageParam.wonum,
				isTode: api.pageParam.isTode ? api.pageParam.isTode : 0
			}, function(ret, err) {
				if (!ret.attachList.length) {
					api.toast({
							msg: "暂无附件",
							duration: 2000,
							location: 'middle'
					});
					return false
				}
				// console.info(JSON.stringify(ret.attachList[0]))
				// return
				uploadXlsx(ret.attachList[0].docinfoid, ret.attachList[0].description)
				// AddData('items', 'ordrDetailContent', ret, false);
				// AddData('tmpList2', 'accessories', ret.attachList);
			})
			// ajaxrd("queryUserGroup", {}, function(ret, err) {
			// 	var datas = ret.data;
			// 	for(var i = 0; i < datas; i++) {
			// 		switch(datas[i].description) {
			// 			case '':
			// 			break;
			// 		}
			// 	}
			// })
		}
		String.prototype.endWith=function(endStr){
	      var d=this.length-endStr.length;
	      return (d>=0&&this.lastIndexOf(endStr)==d);
	  }
		function uploadXlsx(id,name){
			var str = name.toLocaleLowerCase()
			var index = str.lastIndexOf("\.");
			var newString = str.substring(index +1, str.length);
			showExcelFile(baseURL + 'downloadFile?docinfoid=' + id, guid()+'.'+ newString)
			// if(str.endWith("pdf") || str.endWith("doc") || str.endWith("docx") || str.endWith("xls") || str.endWith("xlsx") || str.endWith("ppt") || str.endWith("pptx")){
			// 	showExcelFile(baseURL + 'downloadFile?docinfoid=' + id, guid()+'.'+ newString)
			// }else{
			// 	showRemotePicture(baseURL + 'downloadFile?docinfoid=' + id+'', guid()+'.'+ newString)
			// }
		}
	</script>

</html>
